/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package cocola.impl;

import cocola.Cocola;
import cocola.CocolaPackage;
import cocola.Component;
import cocola.Interface;
import cocola.Primitive;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Cocola</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link cocola.impl.CocolaImpl#getComponents <em>Components</em>}</li>
 *   <li>{@link cocola.impl.CocolaImpl#getPrimitives <em>Primitives</em>}</li>
 *   <li>{@link cocola.impl.CocolaImpl#getClasses <em>Classes</em>}</li>
 *   <li>{@link cocola.impl.CocolaImpl#getInterfaces <em>Interfaces</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CocolaImpl extends EObjectImpl implements Cocola {
	/**
	 * The cached value of the '{@link #getComponents() <em>Components</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComponents()
	 * @generated
	 * @ordered
	 */
	protected EList<Component> components;

	/**
	 * The cached value of the '{@link #getPrimitives() <em>Primitives</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrimitives()
	 * @generated
	 * @ordered
	 */
	protected EList<Primitive> primitives;

	/**
	 * The cached value of the '{@link #getClasses() <em>Classes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClasses()
	 * @generated
	 * @ordered
	 */
	protected EList<cocola.Class> classes;

	/**
	 * The cached value of the '{@link #getInterfaces() <em>Interfaces</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getInterfaces()
	 * @generated
	 * @ordered
	 */
	protected EList<Interface> interfaces;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CocolaImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CocolaPackage.Literals.COCOLA;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Component> getComponents() {
		if (components == null) {
			components = new EObjectContainmentEList<Component>(Component.class, this, CocolaPackage.COCOLA__COMPONENTS);
		}
		return components;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Primitive> getPrimitives() {
		if (primitives == null) {
			primitives = new EObjectContainmentEList<Primitive>(Primitive.class, this, CocolaPackage.COCOLA__PRIMITIVES);
		}
		return primitives;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<cocola.Class> getClasses() {
		if (classes == null) {
			classes = new EObjectContainmentEList<cocola.Class>(cocola.Class.class, this, CocolaPackage.COCOLA__CLASSES);
		}
		return classes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Interface> getInterfaces() {
		if (interfaces == null) {
			interfaces = new EObjectContainmentEList<Interface>(Interface.class, this, CocolaPackage.COCOLA__INTERFACES);
		}
		return interfaces;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CocolaPackage.COCOLA__COMPONENTS:
				return ((InternalEList<?>)getComponents()).basicRemove(otherEnd, msgs);
			case CocolaPackage.COCOLA__PRIMITIVES:
				return ((InternalEList<?>)getPrimitives()).basicRemove(otherEnd, msgs);
			case CocolaPackage.COCOLA__CLASSES:
				return ((InternalEList<?>)getClasses()).basicRemove(otherEnd, msgs);
			case CocolaPackage.COCOLA__INTERFACES:
				return ((InternalEList<?>)getInterfaces()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CocolaPackage.COCOLA__COMPONENTS:
				return getComponents();
			case CocolaPackage.COCOLA__PRIMITIVES:
				return getPrimitives();
			case CocolaPackage.COCOLA__CLASSES:
				return getClasses();
			case CocolaPackage.COCOLA__INTERFACES:
				return getInterfaces();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CocolaPackage.COCOLA__COMPONENTS:
				getComponents().clear();
				getComponents().addAll((Collection<? extends Component>)newValue);
				return;
			case CocolaPackage.COCOLA__PRIMITIVES:
				getPrimitives().clear();
				getPrimitives().addAll((Collection<? extends Primitive>)newValue);
				return;
			case CocolaPackage.COCOLA__CLASSES:
				getClasses().clear();
				getClasses().addAll((Collection<? extends cocola.Class>)newValue);
				return;
			case CocolaPackage.COCOLA__INTERFACES:
				getInterfaces().clear();
				getInterfaces().addAll((Collection<? extends Interface>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CocolaPackage.COCOLA__COMPONENTS:
				getComponents().clear();
				return;
			case CocolaPackage.COCOLA__PRIMITIVES:
				getPrimitives().clear();
				return;
			case CocolaPackage.COCOLA__CLASSES:
				getClasses().clear();
				return;
			case CocolaPackage.COCOLA__INTERFACES:
				getInterfaces().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CocolaPackage.COCOLA__COMPONENTS:
				return components != null && !components.isEmpty();
			case CocolaPackage.COCOLA__PRIMITIVES:
				return primitives != null && !primitives.isEmpty();
			case CocolaPackage.COCOLA__CLASSES:
				return classes != null && !classes.isEmpty();
			case CocolaPackage.COCOLA__INTERFACES:
				return interfaces != null && !interfaces.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //CocolaImpl
